home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / PROGEDIT / 0748.ZIP / COLS < prev    next >
Text File  |  1986-12-29  |  1KB  |  66 lines

  1. /* These macros perform columnar copy and paste. There are no need for */
  2. /* these macros, since these operations are built in to ME. */
  3.  
  4.  
  5. int col_id;
  6.  
  7. init()
  8. {
  9.   assign_key("col_copy",  3);      /* <CTRL> C */
  10.   assign_key("col_paste", 16);     /* <CTRL> P */
  11.   col_id = 0;
  12. }
  13.  
  14. col_copy()
  15. {
  16.   int  line1, line2, col1, col2, width;
  17.   int  old_id;
  18.   string str, foo;
  19.  
  20.   line1 = marked_line();   col1 = marked_col();
  21.   line2 = currlinenum();   col2 = currcol();
  22.  
  23.   if (col_id <= 0)  col_id = create_buffer("$col$.$$$");
  24.  
  25.   old_id = currbuf();
  26.   width  = col2 - col1 + 1;
  27.   goline(line1);  setcol(col1);
  28.  
  29.   while (currlinenum() <= line2)
  30.   {
  31.     str = substr(currline(), col1, width);
  32.     setcurrbuf(col_id);
  33.     gobol();
  34.     insert(str);
  35.     insert("\n");
  36.     setcurrbuf(old_id);
  37.     setcol(col1);  down();
  38.   }
  39.  
  40.   clear_mark();
  41. }
  42.  
  43. col_paste()
  44. {
  45.   int old_id;
  46.   string str;
  47.  
  48.   old_id = currbuf();
  49.   setcurrbuf(col_id);
  50.   goline(1);  gobol();
  51.  
  52.   while (currlinenum() < lastlinenum())
  53.   {
  54.     str = currline();
  55.     setcurrbuf(old_id);
  56.     save_position();
  57.     insert(str);
  58.     restore_position();
  59.     down();
  60.     setcurrbuf(col_id);
  61.     if (!down())  break;
  62.   }
  63.  
  64.   setcurrbuf(old_id);
  65. }
  66.